package com.chagee.store.operation.server.config;

import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.scope.refresh.RefreshScope;
import org.springframework.stereotype.Component;

/**
 * @author: chang.jiawei
 * @date: 2024/06/05
 */
@Component
@Slf4j
@Data
@RequiredArgsConstructor
public class ApolloRefreshConfig {

	private final RefreshScope refreshScope;

	@ApolloConfigChangeListener(value = {"application.yaml"})
	public void onChange(ConfigChangeEvent changeEvent) {
		log.info("before refresh");
		refreshScope.refresh(LarkMessageConfig.class);
		log.info("after refresh");
	}
}
